const {
  Article
} = require('../../model/article')
module.exports = async (req, res) => {
  // 接收客户端传递过来的请求参数
  const {
    publishDate,
    cover,
    content
  } = req.body;
  // 将要修改的文章id
  const id = req.query.id;
  await Article.findOne({
    _id: id
  });
  // res.send(article);
  // 将文章信息更新到数据库
  await Article.updateOne({
    _id: id
  }, {
    publishDate: publishDate,
    cover: cover,
    content: content
  });
  // 重定向到文章列表页面
  res.redirect('/admin/article');
}